laravel seeder with relationships

38

php artisan db:seed --class=UserSeeder
factory(User::class, 10)->create()->each(function ($user) {
    $user->posts()->saveMany(factory(Posts::class, 5)->make());
});

Comments

Submit
0 Comments